﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SharpDiary.Core.Common;

namespace SharpDiary.Core.Controls
{
    public partial class SettingsControlBase : UserControl, ISettingsUI
    {
        #region Fields & Properties

        public Image Logo
        {
            set { lblLogo.Image = value; }
            get { return lblLogo.Image; }
        }

        public string Description
        {
            set { lblDescription.Text = value; }
            get { return lblDescription.Text; }
        }

        /// <summary>
        /// 获取或设置是否显示顶部说明信息。
        /// </summary>
        public bool ShowSettingsBannerPanel
        {
            get { return pnlTop.Visible; }
            set { pnlTop.Visible = value; }
        }

        #endregion

        #region Constructors

        public SettingsControlBase()
        {
            InitializeComponent();

            ResizeRedraw = true;
            DoubleBuffered = true;
        }

        #endregion

        #region Methods

        public virtual bool CheckIfInputOk(ref string errorMessage)
        {
            return true;
        }

        /// <summary>
        /// 加载设置信息。
        /// </summary>
        public virtual void LoadSettingsInfo()
        {

        }

        /// <summary>
        /// 保存设置信息。
        /// </summary>
        /// <returns></returns>
        public virtual bool SaveSettingsInfo()
        {
            return true;
        }

        #endregion

        #region ISettingsService 成员

        public virtual void OnMessageReceived(object sender, MessageReceivedEventArgs e)
        {
            //do nothing.
        }

        public SettingsControlBase GetUIInstance()
        {
            return this;
        }

        #endregion
    }
}
